package com.example.uploadhealth.controller;

import com.example.uploadhealth.domain.ResponseResult;
import com.example.uploadhealth.domain.eneity.User;
import com.example.uploadhealth.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;
    //得的到所有用户
    @GetMapping("/getAllUser")
    public ResponseResult getAllUser(Integer pageNum, Integer pageSize){
        return  userService.getAllUser(pageNum,pageSize);
    }
    @GetMapping("/getAllAdmin")
    public ResponseResult getAllAdmin(){
        return  userService.getAllAdmin();
    }

    //注册
    @PostMapping("/register")
    public ResponseResult register(@RequestBody User user){
        return userService.register(user);
    }
    //删除指定用户
    @DeleteMapping("/delete")
    public ResponseResult deleteUser(Long id){
        System.out.println(id);
        return userService.deletUser(id);
    }

}
